﻿using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace _8.ReplacesForbiddenWordsWithAsterisks
{
    class ReplacesForbiddenWordsWithAsterisks
    {
        static void Main(string[] args)
        {
            string text = "Microsoft announced its next generation PHP compiler today. It is based on .NET Framework 4.0 and is implemented as a dynamic language in CLR.";
            string forbidden = "PHP, CLR, Microsoft";
            string[] forbiddenWords = forbidden.Split(',');
            for (int i = 0; i < forbiddenWords.Length; i++)
            {
                string word = "\\b(" + forbiddenWords[i].Trim() + ")\\b";
                Regex rgx = new Regex(word);
                string fix = new string('*', forbiddenWords[i].Trim().Length);
                text = rgx.Replace(text, fix);
            }
            Console.WriteLine(text);
        }
    }
}
